﻿using Minecraft.Config;
using Minecraft.Model.ReqResp;
using SuperSocket.SocketBase.Command;
using SuperSocket.SocketBase.Protocol;
using System;
using System.Collections.Generic;
using System.Linq;
using Minecraft.Model;
using Minecraft.Model.Furniture;
using Minecraft.Model.Backpack;
using Minecraft.BLL.mysql;
using Minecraft.Config.Csv.CsvCls;

namespace Minecraft.ServerHall.Cmd
{
	public class FurnitureOutputGoodsMove : CommandBase<MinecraftSession, StringRequestInfo>
	{
		public override string Name
		{
			get
			{
				return ProtocolHelper.GetProtocolStr(defCommand);
			}
		}
		private EnumCommand defCommand = EnumCommand.Furniture_FurnitureOutputGoodsMove;
		public override void ExecuteCommand(MinecraftSession session, StringRequestInfo requestInfo)
		{
			var req = requestInfo.GetRequestObj<FurnitureOutputGoodsMoveReq>(session);
			if (req == null)
			{
				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误1：（原因：请求实体为空）" });
				return;
			}
			if (!session.minecraftSessionInfo.IsLogin)
			{
				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误2：（原因：未登录）" });
				return;
			}

			session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误1：（原因：接口已经废弃，请使用接口：{EnumCommand.Backpack_BackpackGoodsExchange.ToString()}）" });
			return;

			//if (JsonConfig.Value.IsDebug)
			//{
			//	req = new FurnitureOutputGoodsMoveReq
			//	{
			//		furnitureId = session.minecraftSessionInfo.furnitureList.FirstOrDefault().FurnitureId,
			//		enumGoodsBelongsToTypeSource = EnumGoodsBelongsToType.Backpack,
			//		enumGoodsBelongsToTypeTarget = EnumGoodsBelongsToType.FurnitureOutput,
			//		GoodsPositionSource = (from inf in session.minecraftSessionInfo.goodsList.GetBackpackGoodsCellInfo()
			//							   where inf.enumGoodsBelongsToType == EnumGoodsBelongsToType.Backpack
			//							   && inf.GoodsItemId == "100000"
			//							   && inf.GoodsList.Count() > 0
			//							   select inf).ToList().FirstOrDefault().GoodsPosition,
			//		GoodsPositionTarget = 0,
			//		//GoodsPositionSource = 1,
			//		//GoodsPositionTarget = (from inf in session.GetBackpackGoodsItemInfoList()
			//		//					   where inf.enumGoodsBelongsToType == EnumGoodsBelongsToType.Backpack
			//		//					   && inf.GoodsNum <= 0
			//		//					   select inf).ToList().FirstOrDefault().GoodsPosition
			//	};
			//}


		//	if (req.guid.IsNullOrWhiteSpace())
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：furnitureId参数为空）" });
		//		return;
		//	}
		//	if (req.GoodsPositionSource < 0)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误4：（原因：GoodsPositionSource < 0）" });
		//		return;
		//	}
		//	if (req.GoodsPositionTarget < 0)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误5：（原因：GoodsPositionTarget < 0）" });
		//		return;
		//	}

		//	//类型限制
		//	List<EnumGoodsBelongsToType> typeList = new List<EnumGoodsBelongsToType>()
		//	{
		//		 EnumGoodsBelongsToType.ShortcutBar,
		//		  EnumGoodsBelongsToType.Backpack,
		//		   EnumGoodsBelongsToType.FurnitureOutput,
		//	};
		//	if (!typeList.Any(m => m == req.enumGoodsBelongsToTypeSource))
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误5：（原因：传入的类型不在此范围【enumGoodsBelongsToTypeSource：{req.enumGoodsBelongsToTypeSource.ToString()}】）" });
		//		return;
		//	}
		//	if (!typeList.Any(m => m == req.enumGoodsBelongsToTypeTarget))
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误5：（原因：传入的类型不在此范围【enumGoodsBelongsToTypeTarget：{req.enumGoodsBelongsToTypeTarget.ToString()}】）" });
		//		return;
		//	}
		//	if (MinecraftConfig.bpShortbarBelongsToTypeList.Any(m => m == req.enumGoodsBelongsToTypeSource) && MinecraftConfig.bpShortbarBelongsToTypeList.Any(m => m == req.enumGoodsBelongsToTypeTarget))
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误5：（原因：两种类型不能同属于快捷栏或者背包）" });
		//		return;
		//	}
		//	//两种类型不能相同
		//	if (req.enumGoodsBelongsToTypeSource == req.enumGoodsBelongsToTypeTarget)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误6：（原因：源物品类型和目标物品类型不能相同）" });
		//		return;
		//	}
		//	//获取产出家具信息
		//	var furniture = session.minecraftSessionInfo.furnitureOutputList.FirstOrDefault(m => m.FurnitureId == req.guid);
		//	if (furniture == null)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误7：（原因：该产出家具信息不存在）" });
		//		return;
		//	}

		//	//if (JsonConfig.Value.IsDebug)
		//	//{
		//	//	//furniture.MaterialGoodsItemIdsPosAndNums = "100000#0#6|100001#1#8";
		//	//	furniture.MaterialGoodsItemIdsPosAndNums = "100000#0#6";
		//	//	//furniture.timeTicksStr = DateTimeOffset.Now.AddSeconds(-500).Ticks.ToString();
		//	//	furniture.timeTicksStr = "";
		//	//	furniture.ResultGoodsNum = 1;
		//	//	furniture.ResultGoodsItemId = "140000";
		//	//}
		//	FurnitureOutputUpgradeInfo furnitureOutputUpgradeInfo = furniture.GetFurnitureOutputUpgradeInfo(session);
		//	//查看升级状态
		//	if (furniture.Upgrade_State_Convert)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：正在升级中，不能调用该接口）" });
		//		return;
		//	}
		//	//暂存操作之前的数据
		//	var beforeFurnitureInfo = furniture.DeepCopy();

		//	var baseRespSource = req.enumGoodsBelongsToTypeSource.GetFurnitureGoodsMovePosBelongsToTypeBaseType(req.guid, req.GoodsPositionSource, session, "FurnitureOutputGoodsMove");
		//	if (baseRespSource.RespLevel != RespLevelEnum.Success)
		//	{
		//		session.Send(defCommand, req, baseRespSource);
		//		return;
		//	}
		//	var baseRespTarget = req.enumGoodsBelongsToTypeTarget.GetFurnitureGoodsMovePosBelongsToTypeBaseType(req.guid, req.GoodsPositionTarget, session, "FurnitureOutputGoodsMove");
		//	if (baseRespTarget.RespLevel != RespLevelEnum.Success)
		//	{
		//		session.Send(defCommand, req, baseRespTarget);
		//		return;
		//	}

		//	Mod_Drawing mod_Furniture = furniture.GetMod_FurnitureInfo();
		//	if (mod_Furniture == null)
		//	{
		//		session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：mod_Furniture 配置表不存在）" });
		//		return;
		//	}

		//	//添加操作影响的positionOptList
		//	List<BackpackGoodsPositionOpt> positionOptList = new List<BackpackGoodsPositionOpt>();

		//	//源位置是背包
		//	if (MinecraftConfig.bpShortbarBelongsToTypeList.Any(m => m == req.enumGoodsBelongsToTypeSource))
		//	{
		//		//背包数据（源位置）
		//		var backpackGoodsInfo = session.minecraftSessionInfo.goodsList.FirstOrDefault(m =>
		//			m.enumGoodsBelongsToType_Convert == req.enumGoodsBelongsToTypeSource
		//			&& m.GoodsPosition == req.GoodsPositionSource && m.Num > 0);
		//		if (backpackGoodsInfo == null)
		//		{
		//			session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：源位置中的格子物品数量为空）" });
		//			return;
		//		}

		//		//产出家具（目标位置）
		//		bool isProduct = false;
		//		int num = 0;
		//		var furnitureOutputMaterialGoodsInfo = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert().FirstOrDefault(m => m.GoodsPosition == req.GoodsPositionTarget);
		//		var cellTotalNum = furniture.GetMod_FurnitureInfo().GetCellTotalNum_Convert(furniture.Level);
		//		if (req.GoodsPositionTarget == cellTotalNum - 1) //产物位置
		//		{
		//			isProduct = true;
		//		}
		//		else
		//		{
		//			isProduct = false;
		//		}

		//		if (isProduct)
		//		{
		//			session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：不能拖放到产物格子）" });
		//			return;
		//		}

		//		if (!isProduct)
		//		{
		//			//如果家具需要燃料，并且拖到家具的位置在燃料位置上，如果放置的物品不是燃料，则不允许放置
		//			if (mod_Furniture.If_buring_Convert)
		//			{
		//				if (req.GoodsPositionTarget == cellTotalNum - 2) //燃料位置
		//				{
		//					//Mod_Items mod_Items = CsvConfig.itemsList.FirstOrDefault(m => m.Id == backpackGoodsInfo.GoodsItemId);
		//					Mod_Items mod_Items = CsvConfig.GetMod_ItemsInfoById(backpackGoodsInfo.GoodsItemId);
		//					if (mod_Items == null)
		//					{
		//						session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：mod_Items 配置表不存在）" });
		//						return;
		//					}
		//					if (mod_Items.modAttributeInfo_Convert == null || mod_Items.modAttributeInfo_Convert.enumAttribute != EnumAttribute.BurnVal)
		//					{
		//						session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：燃料框只能拖放燃料，所以操作失败）" });
		//						return;
		//					}
		//				}
		//				else //配方位置
		//				{
		//					//判断是否是配方的一种
		//					var isRecipe = furniture.isFurnitureOutputRecipe(backpackGoodsInfo.GoodsItemId);
		//					if (!isRecipe)
		//					{
		//						session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误8：（原因：该物品【backpackGoodsList.FirstOrDefault().GoodsItemId：{backpackGoodsInfo.GoodsItemId}】不属于配方，不允许拖动到配方格子中1）" });
		//						return;
		//					}
		//				}
		//			}
		//			else //不需要燃料
		//			{
		//				//判断是否是配方的一种
		//				var isRecipe = furniture.isFurnitureOutputRecipe(backpackGoodsInfo.GoodsItemId);
		//				if (!isRecipe)
		//				{
		//					session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误8：（原因：该物品【backpackGoodsList.FirstOrDefault().GoodsItemId：{backpackGoodsInfo.GoodsItemId}】不属于配方，不允许拖动到配方格子中2）" });
		//					return;
		//				}
		//			}

		//			//如果源位置与目标位置是相同物品，或者目标格子为空
		//			if (furnitureOutputMaterialGoodsInfo != null && furnitureOutputMaterialGoodsInfo.GoodsItemId == backpackGoodsInfo.GoodsItemId
		//				|| furnitureOutputMaterialGoodsInfo == null)
		//			{
		//				if (furnitureOutputMaterialGoodsInfo == null)
		//				{
		//					furnitureOutputMaterialGoodsInfo = new FurnitureOutputMaterialGoodsInfo
		//					{
		//						Num = 0,
		//						GoodsPosition = req.GoodsPositionTarget,
		//						GoodsItemId = backpackGoodsInfo.GoodsItemId
		//					};
		//				}
		//				num = furnitureOutputMaterialGoodsInfo.Num;

		//				//从配置中读取指定物品存放数量上限（由于源格子与目标格子的物品ItemId相同，所以可以选择源格子的物品ItemId）
		//				var destGoodsItemMaxNum = session.GetMaxCellNumConvert(backpackGoodsInfo.GoodsItemId);
		//				if (num >= destGoodsItemMaxNum)
		//				{
		//					session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误12：（原因：移动无效，交换相同物品时，会产生堆叠，如果目标位置已经满了，则无法操作）" });
		//					return;
		//				}
		//				//判断目标位置还可以放多少个，才能放满
		//				var subValue = destGoodsItemMaxNum - num;
		//				var canTakeNum = Math.Min(subValue, backpackGoodsInfo.Num);
		//				//var takeGoodsSourceList = backpackGoodsInfo.Take(subValue).ToList();
		//				backpackGoodsInfo.Num -= canTakeNum;
		//				//这里有Goods GUID 的消失
		//				//takeGoodsSourceList.ForEach(item =>
		//				//{
		//				//	session.minecraftSessionInfo.goodsList.RemoveAll(m => m.GoodsId == item.GoodsId);
		//				//});
		//				//将背包格子中的物品移动到产出家具的格子中
		//				if (!isProduct)
		//				{
		//					furnitureOutputMaterialGoodsInfo.Num += canTakeNum;
		//					//主动触发元素属性值的改变事件
		//					furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(furnitureOutputMaterialGoodsInfo);
		//				}
		//				else
		//				{
		//					furniture.Output_ResultGoodsItemId = backpackGoodsInfo.GoodsItemId;
		//					furniture.Output_ResultGoodsNum += canTakeNum;
		//				}

		//			}
		//			else
		//			{
		//				//交换
		//				//backpackGoodsInfo.ForEach(item =>
		//				//{
		//				//	session.minecraftSessionInfo.goodsList.RemoveAll(m => m.GoodsId == item.GoodsId);
		//				//});
		//				////移动到背包
		//				//for (int i = 0; i < furnitureOutputMaterialGoodsInfo.Num; i++)
		//				//{
		//				//	session.minecraftSessionInfo.goodsList.Add(new GoodsModel()
		//				//	{
		//				//		BelongsTo = (int)req.enumGoodsBelongsToTypeSource,
		//				//		guid = "",
		//				//		GoodsId = StringHelper.GetGuidStr(),
		//				//		PlayerId = session.minecraftSessionInfo.player.PlayerId,
		//				//		GoodsPosition = req.GoodsPositionSource,
		//				//		GoodsItemId = furnitureOutputMaterialGoodsInfo.GoodsItemId,
		//				//		WastageValue = 100
		//				//	});
		//				//}

		//				var backpackGoodsInfoCopy = backpackGoodsInfo.DeepCopy();

		//				backpackGoodsInfo.BelongsTo = (int)req.enumGoodsBelongsToTypeTarget;
		//				backpackGoodsInfo.GoodsId = StringHelper.GetGuidStr();
		//				backpackGoodsInfo.GoodsItemId = furnitureOutputMaterialGoodsInfo.GoodsItemId;
		//				backpackGoodsInfo.GoodsPosition = furnitureOutputMaterialGoodsInfo.GoodsPosition;
		//				//goodsSourceInfo.guid = destinationCopy.guid;
		//				backpackGoodsInfo.Num = furnitureOutputMaterialGoodsInfo.Num;
		//				//goodsSourceInfo.PlayerId = destinationCopy.PlayerId;
		//				backpackGoodsInfo.WastageValue = 100;

		//				furnitureOutputMaterialGoodsInfo.GoodsItemId = backpackGoodsInfoCopy.GoodsItemId;
		//				furnitureOutputMaterialGoodsInfo.Num = backpackGoodsInfoCopy.Num;
		//				//主动触发元素属性值的改变事件
		//				furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(furnitureOutputMaterialGoodsInfo);
		//			}
		//			//移动成功
		//			positionOptList.Add(new BackpackGoodsPositionOpt
		//			{
		//				enumGoodsBelongsToType = req.enumGoodsBelongsToTypeSource,
		//				GoodsPosition = req.GoodsPositionSource,
		//				guid = backpackGoodsInfo.guid
		//			});
		//			positionOptList.Add(new BackpackGoodsPositionOpt
		//			{
		//				enumGoodsBelongsToType = req.enumGoodsBelongsToTypeTarget,
		//				GoodsPosition = req.GoodsPositionTarget,
		//				guid = furniture.FurnitureId
		//			});
		//		}
		//		else
		//		{
		//			//是产物
		//			if (!furniture.Output_ResultGoodsItemId.IsNullOrWhiteSpace() && furniture.Output_ResultGoodsItemId != backpackGoodsInfo.GoodsItemId)
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误11：（原因：源格子为背包中的格子，源格子与目标格子存放不同物品，并且目标格子不为空，则无法移动）" });
		//				return;
		//			}

		//		}
		//	}
		//	//源位置是产出家具
		//	else if (req.enumGoodsBelongsToTypeSource == EnumGoodsBelongsToType.FurnitureOutput)
		//	{
		//		//产出家具（源位置）
		//		string goodsItemId = "";
		//		int num = 0;

		//		bool isProduct = false;
		//		var furnitureOutputMaterialGoodsInfo = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert().FirstOrDefault(m => m.GoodsPosition == req.GoodsPositionSource);
		//		var cellTotalNum = furniture.GetMod_FurnitureInfo().GetCellTotalNum_Convert(furniture.Level);
		//		if (req.GoodsPositionSource == cellTotalNum - 1) //产物位置
		//		{
		//			isProduct = true;
		//		}
		//		else
		//		{
		//			isProduct = false;
		//		}
		//		if (!isProduct)
		//		{
		//			if (furnitureOutputMaterialGoodsInfo == null)
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误13：（原因：源位置中的格子物品数量为空）" });
		//				return;
		//			}
		//			goodsItemId = furnitureOutputMaterialGoodsInfo.GoodsItemId;
		//			num = furnitureOutputMaterialGoodsInfo.Num;
		//		}
		//		else
		//		{
		//			//是产物
		//			if (furniture.Output_ResultGoodsItemId.IsNullOrWhiteSpace())
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误14：（原因：源位置（家具）中的产物格子物品ItemId为空）" });
		//				return;
		//			}
		//			if (!session.IsExistItemsOrBlocks(furniture.Output_ResultGoodsItemId))
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误15：（原因：源位置（家具）中的产物格子物品或者方块不存在）" });
		//				return;
		//			}
		//			if (furniture.Output_ResultGoodsNum <= 0)
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误16：（原因：源位置（家具）中的产物格子物品或者方块个数小等于0）" });
		//				return;
		//			}
		//			goodsItemId = furniture.Output_ResultGoodsItemId;
		//			num = furniture.Output_ResultGoodsNum;
		//		}

		//		//背包数据（目标位置）
		//		var backpackGoodsInfo = session.minecraftSessionInfo.goodsList.FirstOrDefault(m =>
		//			 m.enumGoodsBelongsToType_Convert == req.enumGoodsBelongsToTypeTarget
		//			&& m.GoodsPosition == req.GoodsPositionTarget);
		//		//如果源位置与目标位置是相同物品，或者目标格子为空
		//		if (backpackGoodsInfo != null && backpackGoodsInfo.GoodsItemId == goodsItemId
		//			|| (backpackGoodsInfo == null)
		//			)
		//		{
		//			if (backpackGoodsInfo == null)
		//			{
		//				backpackGoodsInfo = new GoodsModel()
		//				{
		//					BelongsTo = (int)req.enumGoodsBelongsToTypeTarget,
		//					GoodsId = StringHelper.GetGuidStr(),
		//					GoodsPosition = req.GoodsPositionTarget,
		//					GoodsItemId = goodsItemId,
		//					Num = 0,
		//					guid = "",
		//					PlayerId = session.minecraftSessionInfo.player.PlayerId,
		//					WastageValue = 100
		//				};
		//				session.minecraftSessionInfo.goodsList.Add(backpackGoodsInfo);
		//			}
		//			//从配置中读取指定物品存放数量上限（由于源格子与目标格子的物品ItemId相同，所以可以选择源格子的物品ItemId）
		//			var destGoodsItemMaxNum = session.GetMaxCellNumConvert(goodsItemId);
		//			//判断目标位置还可以放多少个，才能放满
		//			var subValue = destGoodsItemMaxNum - backpackGoodsInfo.Num;
		//			//得到可以移动的个数
		//			var canMoveNum = Math.Min(subValue, num);

		//			////此处有新的goods GUID 产生
		//			//List<GoodsModel> newGoodsList = new List<GoodsModel>();
		//			//for (int canMoveIndex = 0; canMoveIndex < canMoveNum; canMoveIndex++)
		//			//{
		//			//	GoodsModel goodsModel = new GoodsModel
		//			//	{
		//			//		BelongsTo = (int)req.enumGoodsBelongsToTypeTarget,
		//			//		GoodsId = StringHelper.GetGuidStr(),
		//			//		GoodsItemId = goodsItemId,
		//			//		GoodsPosition = req.GoodsPositionTarget,
		//			//		PlayerId = session.minecraftSessionInfo.player.PlayerId,
		//			//		WastageValue = 100,
		//			//		guid = "",
		//			//	};
		//			//	newGoodsList.Add(goodsModel);
		//			//}

		//			backpackGoodsInfo.Num += canMoveNum;

		//			//更新源格子的物品个数
		//			if (!isProduct)
		//			{
		//				furnitureOutputMaterialGoodsInfo.Num -= canMoveNum;
		//				furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(furnitureOutputMaterialGoodsInfo);
		//			}
		//			else
		//			{
		//				furniture.Output_ResultGoodsNum -= canMoveNum;
		//			}
		//		}
		//		else
		//		{
		//			//交换，不同物品
		//			if (!isProduct)
		//			{
		//				var isRecipe = furniture.isFurnitureOutputRecipe(backpackGoodsInfo.GoodsItemId);

		//				if (!isRecipe)
		//				{
		//					session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误8：（原因：要交换的物品不属于配方，不允许交换）" });
		//					return;
		//				}

		//				////交换
		//				//backpackGoodsInfo.ForEach(item =>
		//				//{
		//				//	session.minecraftSessionInfo.goodsList.RemoveAll(m => m.GoodsId == item.GoodsId);
		//				//});

		//				////此处有新的goods GUID 产生
		//				//List<GoodsModel> newGoodsList = new List<GoodsModel>();
		//				//for (int i = 0; i < num; i++)
		//				//{
		//				//	GoodsModel goodsModel = new GoodsModel
		//				//	{
		//				//		BelongsTo = (int)req.enumGoodsBelongsToTypeTarget,
		//				//		GoodsId = StringHelper.GetGuidStr(),
		//				//		GoodsItemId = goodsItemId,
		//				//		GoodsPosition = req.GoodsPositionTarget,
		//				//		PlayerId = session.minecraftSessionInfo.player.PlayerId,
		//				//		WastageValue = 100,
		//				//		guid = "",
		//				//		 Num = 
		//				//	};
		//				//	newGoodsList.Add(goodsModel);
		//				//}
		//				////更新目标格子的物品
		//				//session.minecraftSessionInfo.goodsList.AddRange(newGoodsList);

		//				var backpackGoodsInfoCopy = backpackGoodsInfo.DeepCopy();

		//				backpackGoodsInfo.BelongsTo = (int)req.GoodsPositionSource;
		//				backpackGoodsInfo.GoodsId = StringHelper.GetGuidStr();
		//				backpackGoodsInfo.GoodsItemId = furnitureOutputMaterialGoodsInfo.GoodsItemId;
		//				backpackGoodsInfo.GoodsPosition = furnitureOutputMaterialGoodsInfo.GoodsPosition;
		//				//goodsSourceInfo.guid = destinationCopy.guid;
		//				backpackGoodsInfo.Num = furnitureOutputMaterialGoodsInfo.Num;
		//				//goodsSourceInfo.PlayerId = destinationCopy.PlayerId;
		//				backpackGoodsInfo.WastageValue = 100;

		//				furnitureOutputMaterialGoodsInfo.GoodsItemId = backpackGoodsInfoCopy.GoodsItemId;
		//				furnitureOutputMaterialGoodsInfo.Num = backpackGoodsInfoCopy.Num;
		//				furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(furnitureOutputMaterialGoodsInfo);
		//			}
		//			else
		//			{
		//				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误16：（原因：如果背包中有物品，则不能从产出家具的产物格子移动到背包中与产物不同的格子中）" });
		//				return;
		//			}

		//		}
		//		//移动成功
		//		positionOptList.Add(new BackpackGoodsPositionOpt
		//		{
		//			enumGoodsBelongsToType = req.enumGoodsBelongsToTypeSource,
		//			GoodsPosition = req.GoodsPositionSource,
		//			 guid = furniture.FurnitureId
		//		});
		//		positionOptList.Add(new BackpackGoodsPositionOpt
		//		{
		//			enumGoodsBelongsToType = req.enumGoodsBelongsToTypeTarget,
		//			GoodsPosition = req.GoodsPositionTarget,
		//			 guid = backpackGoodsInfo.guid
		//		});
		//	}
		//	else
		//	{
		//		//前面已经做了判断，这里不作处理
		//	}

		//	//change时间ticks
		//	var separatorChar = '|';
		//	var timeNow = DateTimeOffset.Now;

		//	//获取之前的产出条件
		//	EnumFurnitureOutputState enumFurnitureOutputStateBefore = beforeFurnitureInfo.GetFurnitureOutputState(session);
		//	//获取之后的产出条件
		//	EnumFurnitureOutputState enumFurnitureOutputStateAfter = furniture.GetFurnitureOutputState(session);
		//	switch (enumFurnitureOutputStateBefore)
		//	{
		//		case EnumFurnitureOutputState.NotStart:
		//			{
		//				switch (enumFurnitureOutputStateAfter)
		//				{
		//					case EnumFurnitureOutputState.NotStart:
		//						{
		//							furniture.Output_timeTicksStr = "";
		//						}
		//						break;
		//					case EnumFurnitureOutputState.Progressing:
		//						{
		//							furniture.Output_timeTicksStr = timeNow.Ticks.ToString();
		//						}
		//						break;
		//					case EnumFurnitureOutputState.PauseIn:
		//						{
		//							//不存在这种情况
		//						}
		//						break;
		//					default:
		//						break;
		//				}
		//			}
		//			break;
		//		case EnumFurnitureOutputState.Progressing:
		//			{
		//				switch (enumFurnitureOutputStateAfter)
		//				{
		//					case EnumFurnitureOutputState.NotStart:
		//						{
		//							//先计算剩余材料，剩余燃料，总共的产物，赋值给furniture对象

		//							furniture.Output_timeTicksStr = "";

		//						}
		//						break;
		//					case EnumFurnitureOutputState.Progressing:
		//						{
		//							//不做任何操作
		//						}
		//						break;
		//					case EnumFurnitureOutputState.PauseIn:
		//						{
		//							var beforeTicksList = furniture.Output_timeTicksStr.Split(new char[] { separatorChar }, StringSplitOptions.RemoveEmptyEntries).ToList();
		//							if (!beforeTicksList.Any())
		//							{
		//								beforeTicksList.Add(timeNow.Ticks.ToString());
		//							}
		//							beforeTicksList.Add(timeNow.Ticks.ToString());
		//							furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
		//						}
		//						break;
		//					default:
		//						break;
		//				}
		//			}
		//			break;
		//		case EnumFurnitureOutputState.PauseIn:
		//			{
		//				switch (enumFurnitureOutputStateAfter)
		//				{
		//					case EnumFurnitureOutputState.NotStart:
		//						{
		//							//先计算剩余材料，剩余燃料，总共的产物，赋值给furniture对象

		//							furniture.Output_timeTicksStr = "";
		//						}
		//						break;
		//					case EnumFurnitureOutputState.Progressing:
		//						{
		//							var beforeTicksList = furniture.Output_timeTicksStr.Split(new char[] { separatorChar }, StringSplitOptions.RemoveEmptyEntries).ToList();
		//							if (!beforeTicksList.Any())
		//							{
		//								beforeTicksList.Add(timeNow.Ticks.ToString());
		//							}
		//							beforeTicksList.Add(timeNow.Ticks.ToString());
		//							furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
		//						}
		//						break;
		//					case EnumFurnitureOutputState.PauseIn:
		//						{
		//							//不做任何操作
		//						}
		//						break;
		//					default:
		//						break;
		//				}
		//			}
		//			break;
		//		default:
		//			break;
		//	}

		//	FurnitureOutputInfo furnitureOutputInfo = null;
		//	var baseResp = furniture.GetFurnitureOutputInfo(session, out furnitureOutputInfo);
		//	if (baseResp.RespLevel != RespLevelEnum.Success)
		//	{
		//		session.Send(defCommand, req, baseResp);
		//		return;
		//	}

		//	//组装响应数据
		//	List<BackpackCellInfo> posGoodsinfoList = new List<BackpackCellInfo>();
		//	//获取影响的位置列表（只有两个，一个背包，一个家具）
		//	positionOptList.ForEach(optItem =>
		//	{
		//		if (MinecraftConfig.bpShortbarBelongsToTypeList.Any(m => m == optItem.enumGoodsBelongsToType))
		//		{
		//			//找到受影响的物品位置信息
		//			posGoodsinfoList = session.minecraftSessionInfo.goodsList.Where(m => m.enumGoodsBelongsToType_Convert == optItem.enumGoodsBelongsToType && m.GoodsPosition == optItem.GoodsPosition).GetBackpackGoodsCellInfo();
		//			//if (posGoodsinfoList == null || !posGoodsinfoList.Any())
		//			//{
		//			//	posGoodsinfoList.Add(new BackpackCellInfo
		//			//	{
		//			//		enumGoodsBelongsToType = optItem.enumGoodsBelongsToType,
		//			//		GoodsList = new List<BackpackGoodsInfo>(),
		//			//		WastageValue = 0,
		//			//		GoodsPosition = optItem.GoodsPosition,
		//			//		GoodsItemId = ""
		//			//	});
		//			//}
		//		}
		//		else if (optItem.enumGoodsBelongsToType == EnumGoodsBelongsToType.FurnitureOutput)
		//		{
		//			//不作处理
		//		}
		//		else
		//		{
		//			//不作处理
		//		}
		//	});

		//	session.minecraftSessionInfo.goodsList.RemoveAll(m => m.Num <= 0);

		//	var resp = new FurnitureOutputGoodsMoveResp
		//	{
		//		posGoodsinfoList = posGoodsinfoList,
		//		furnitureOutputInfo = furnitureOutputInfo
		//	};
		//	session.Send(defCommand, req, resp);
		}
	}
}
